var net = require('net');

const addr = {
    to: {
        host: "localhost",
        port: 3000
    },
    from: {
        host: "localhost",
        port: 8000
    }
}

net.createServer(function (from) {
    var to = net.createConnection({
        host: addr.to.host,
        port: addr.to.port
    });
    from.pipe(to);
    to.on('connect', function () {
        console.log("to connected")
    });
    from.on("close", function () {
        console.log("from disconnected")
    });

    to.pipe(from);
}).listen(addr.from.host, addr.from.port);